package uk.ac.lkl.lpp.model.ldo;



import java.util.*;


/**
 * A module.
 * 
 * In addition to title and description fields, this class also keeps
 * track of the teaching methods used in the module and the number of
 * hours corresponding to each one.
 * 
 * @author Darren Pearce
 * @version $Revision: 353 $
 * @version $Date: 2007-10-30 13:18:52 +0000 (Tue, 30 Oct 2007) $
 * 
 */
public class Module extends LearningEntity {

    /**
     * A map from teaching method to the number of hours for that
     * method for this module.
     * 
     */
    private HashMap<TeachingMethod, Float> teachingMethodToHours;


    /**
     * Create a new instance with the given title.
     * 
     * @param title
     *            the title
     * 
     */
    public Module(String title) {
        super(title);
        teachingMethodToHours = new HashMap<TeachingMethod, Float>();
    }


    /**
     * Add the specified teaching method to this module with zero
     * hours.
     * 
     * @param teachingMethod
     * 
     */
    public void addTeachingMethod(TeachingMethod teachingMethod) {
        addTeachingMethod(teachingMethod, 0);
    }


    /**
     * Add the specified teaching method to this module with the given
     * number of hours.
     * 
     * Currently, this is identical to calling
     * updateTeachingMethodHours.
     * 
     * @param teachingMethod
     *            the teaching method
     * 
     * @param hours
     *            the number of hours
     * 
     */
    public void addTeachingMethod(TeachingMethod teachingMethod, float hours) {
        // can only do this at moment -- won't be able to eventually
        // perhaps
        updateTeachingMethodHours(teachingMethod, hours);
    }


    /**
     * Update the number of hours for a given teaching method.
     * 
     * Currently, no change listening is implemented. It should be
     * really.
     * 
     * @param teachingMethod
     *            the teaching method
     * 
     * @param hours
     *            the number of hours
     * 
     */
    public void updateTeachingMethodHours(TeachingMethod teachingMethod,
                                          float hours) {
        teachingMethodToHours.put(teachingMethod, hours);
    }


    public String getType() {
        return "Module";
    }

}
